<?php
/**
 * Created by PhpStorm.
 * User: Sun Jian
 * Date: 2018/1/3
 * Time: 15:39
 */

namespace app\models;

use Yii;

class BaseModel extends \yii\db\ActiveRecord
{
    public static function getDb()
    {
        $dbname=Yii::$app->session->get("dbname");
        $connection = new \yii\db\Connection([
            'dsn' => 'mysql:host=127.0.0.1;dbname='.$dbname,
             'username' => 'root',
             'password' => 'admin',
        ]);
        $connection->open();

        return $connection;
    }
}